home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue37 / outlook / mapi / imessage.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-06-19  |  8.5 KB  |  222 lines

  1. {++
  2.  
  3.   i m e s s a g e . p a s
  4.  
  5.   Abstract:
  6.  
  7.     Automatic conversion of imessage.h.
  8.  
  9.   Comments:
  10.  
  11.     This source file automatically converted by
  12.     htrans 0.91 beta 1 Copyright (c) 1997 Alexander Staubo
  13.  
  14.   Revision history:
  15.  
  16.     18-06-1997 20:53 alex  [Autogenerated]
  17.     18-06-1997 20:53 alex  Retouched for release
  18.  
  19. --}
  20.  
  21. unit IMessage;
  22.  
  23. {$A+}
  24. {$MINENUMSIZE 4}
  25.  
  26. interface
  27.  
  28. uses
  29.   Windows, SysUtils, ActiveX,
  30.   MapiDefs;
  31.  
  32. (*
  33.  *  I M E S S A G E . H
  34.  *
  35.  *  External definitions for MAPI's IMessage-on-IStorage facility
  36.  *
  37.  *  Copyright 1986-1996 Microsoft Corporation. All Rights Reserved.
  38.  *)
  39.  
  40. type
  41.   PMSGSESS = Pointer;
  42.  
  43. {  Typedef of optional callback routine to be called on last release of
  44.  *  top-level messages opened with OpenIMsgOnIStg
  45.  }
  46.  
  47. type
  48.   TMSGCALLRELEASE = procedure (ulCallerData : ULONG;
  49.     lpMessage : MapiDefs.IMessage); stdcall;
  50.   
  51. { DLL Entry Points (found in mapiu.dll) }
  52.  
  53. (* OpenIMsgSession
  54.  * CloseIMsgSession
  55.  *
  56.  * These entry points allow the caller to "wrap" the creation of messages
  57.  * inside a session, so that when the session is closed, all messages
  58.  * created within that session are closed as well. Use of IMSG sessions
  59.  * is optional. If OpenIMsgOnIStg is called with a NULL for the lpmsgsess
  60.  * parameter, the message is created independent of any session, and has
  61.  * no way to be shutdown. If the caller forgets to release the message, or
  62.  * to release open tables within the message, the memory will be leaked until
  63.  * the external application terminates.
  64.  *)
  65.  
  66. function OpenIMsgSession (
  67.   lpMalloc : IMalloc;                          { -> Co malloc object          }
  68.   ulFlags : ULONG;                             { reserved. Must be zero.      }
  69.   var lppMsgSess : PMSGSESS) : SCODE; stdcall; { <- message session object    }
  70.  
  71. procedure CloseIMsgSession (
  72.   lpMsgSess : PMSGSESS); stdcall;              { -> message session object    }
  73.  
  74. (*  OpenIMsgOnIStg - Main entry point
  75.  *
  76.  *  NOTE 1:  The IStg must be opened with STGM_TRANSACTED if STGM_READWRITE
  77.  *  is specified.  Since messages don't support a write only mode, IMessage
  78.  *  doesn't allow a storage object opened in write only mode. If the storage
  79.  *  is opened STGM_READ, then STGM_TRANSACTED is NOT required.
  80.  *
  81.  *  NOTE 2:  The lpMapiSup parameter is optional.  If supplied then IMessage 
  82.  *  will support the MAPI_DIALOG and ATTACH_DIALOG flags (by calling 
  83.  *  support method: DoMCDialog) on CopyTo and DeleteAttach methods.  
  84.  *  If lpMapiSup is not supplied (i.e. passed 0) then dialog flags will be
  85.  *  ignored.  If supplied then ModifyRecipients will attempt to convert 
  86.  *  short term entryids to long term entryids (by calling support method 
  87.  *  OpenAddressBook and calls on the returned object).  If not supplied 
  88.  *  then short term entryid's will be stored without conversion.
  89.  *
  90.  *  NOTE 3:  The lpfMsgCallRelease parameter is optional.  If supplied then
  91.  *  IMessage will call the routine when the last release on (the toplevel only)
  92.  *  message is called.  It is intended to allow the callee to free the IStorage
  93.  *  that contains the message.  IMessage will not use the IStorage object after
  94.  *  making this call.
  95.  *
  96.  *  NOTE 4:  Behavior of multiple opens of sub-objects (Attachments, Streams,
  97.  *  Storages, Messages, etc.) within a message is deliberately undefined in
  98.  *  MAPI.  This implementation allows them, but will do it by AddRef'ing the
  99.  *  existing open and returning it to the caller of OpenAttachment or
  100.  *  OpenProperty.  This means that whatever access mode the first open on a
  101.  *  specific Attachment or Property had is what all others will get regardless
  102.  *  of what the subsequent opens asked for.
  103.  *
  104.  *  NOTE 5:  There is currently one flag defined for use with the ulFlags
  105.  *  parameter. The IMSG_NO_ISTG_COMMIT flag controls whether the commit
  106.  *  method of IStorage is called when the client calls SaveChanges on the
  107.  *  IMessage object. Some clients of IMessage may wish to commit the IStorage
  108.  *  themselves after writing additional data to the storage (beyond what
  109.  *  IMessage itself writes). To aid in this, the IMessage implementation
  110.  *  guarantees to name all sub-storages starting with "__". Therefore,
  111.  *  if the client keeps its names out of that namespace, there will be no
  112.  *  accidental collisions.
  113.  *
  114.  *  WARNING:
  115.  *
  116.  *  This implementation of IMessage will support OpenProperty w/MAPI_CREATE
  117.  *  where the source interface is IID_IStorage if the property id is
  118.  *  'PR_ATTACH_DATA'.  Once this has been done, the caller has an IStorage
  119.  *  interface on this property.  This is ok and should allow for
  120.  *  easier implementation of OLE 2.0 Server functionality.  However, if you
  121.  *  pass in the new IStorage ptr (to the attachment data) through the
  122.  *  OpenIMsgOnIStg entry point and then proceed to release things in the
  123.  *  wrong order we will make no attempt to behave in a predictable fashion.
  124.  *  Keep in mind that the correct method for placing a message into an
  125.  *  attachment is to call OpenProperty where the source interface is
  126.  *  IID_IMessage.  The IStorage interface is supported to allow an easy way
  127.  *  to stick a WWord doc. into an attachment w/o converting to/from IStream.
  128.  *
  129.  *)
  130.  
  131. function OpenIMsgOnIStg (
  132.   lpMsgSess : PMSGSESS;                { -> message session obj (optional) }
  133.   lpAllocateBuffer : PALLOCATEBUFFER;  { -> AllocateBuffer memory routine  }
  134.   lpAllocateMore : PALLOCATEMORE;      { -> AllocateMore memory routine    }
  135.   lpFreeBuffer : PFREEBUFFER;          { -> FreeBuffer memory routine      }
  136.   lpMalloc : IMalloc;                  { -> Co malloc object               }
  137.   lpMapiSup : Pointer;                 { -> MAPI Support Obj (optional)    }
  138.   lpStg : IStorage;                    { -> open IStorage containing msg   }
  139.   var lpfMsgCallRelease : TMSGCALLRELEASE;
  140.                                        { -> release callback rtn (opt) }
  141.   ulCallerData : ULONG;                { caller data returned in callback  }
  142.   ulFlags : ULONG;                     { -> flags (controls istg commit)   }
  143.   out lppMsg : MapiDefs.IMessage) : SCODE; stdcall;
  144.                                        { <- open message object            }
  145.  
  146. const
  147.   IMSG_NO_ISTG_COMMIT = (ULONG($00000001));
  148.  
  149. { NOTE: Property Attributes are specific to this IMessage on IStorage      }
  150.  
  151. { implementation and are not a part of standard MAPI 1.0 property methods  }
  152.  
  153. { Property Attributes }
  154.  
  155. const
  156.   PROPATTR_MANDATORY = (ULONG($00000001));
  157.   PROPATTR_READABLE = (ULONG($00000002));
  158.   PROPATTR_WRITEABLE = (ULONG($00000004));
  159.   PROPATTR_NOT_PRESENT = (ULONG($00000008));
  160.  
  161. { Attribute Array }
  162.  
  163. type
  164.   TSPropAttrArray =     
  165.     record
  166.       cValues : ULONG;
  167.       aPropAttr : array[0..MAPI_DIM - 1] of ULONG;
  168.     end;
  169.     
  170.   PSPropAttrArray = ^TSPropAttrArray;
  171.   
  172. (*  GetAttribIMsgOnIStg - To get attributes on properties
  173.  *
  174.  *  This call is provided because there is no method of IMAPIPropSet to allow
  175.  *  getting attributes.
  176.  *)
  177.  
  178. function GetAttribIMsgOnIStg (lpObject : Pointer;
  179.   lpPropTagArray : PSPropTagArray;
  180.   var lppPropAttrArray : PSPropAttrArray) : HResult; stdcall;
  181.  
  182. (*  SetAttribIMsgOnIStg - To set attributes on properties
  183.  *
  184.  *  This call is provided because there is no method of IMAPIPropSet to allow
  185.  *  setting of attributes.
  186.  *)
  187.  
  188. function SetAttribIMsgOnIStg (lpObject : Pointer;
  189.   lpPropTags : PSPropTagArray; lpPropAttrs : PSPropAttrArray;
  190.   var lppPropProblems : PSPropProblemArray) : HResult; stdcall;
  191.  
  192. (*  MapStorageSCode - To map an IStorage hResult to a MAPI sCode value
  193.  *
  194.  *  This call is provided for the internal use of PDK components that base
  195.  *  their message implementations on IMessage.  Since these components must
  196.  *  open the storage themselves, there is a common need to map OLE 2.0
  197.  *  Storage error returns to MAPI sCodes.
  198.  *
  199.  *  WARNING:    There is no guarantee that this entry point will exist in
  200.  *  shipped versions of mapiu.dll.
  201.  *)
  202.  
  203. function MapStorageSCode (StgSCode : SCODE) : SCODE; stdcall;
  204.  
  205. implementation
  206.  
  207. const
  208.   Mapi32Dll = 'mapi32.dll';
  209.  
  210. {!! Note: Entry points have been verified with release versions of
  211.   Windows NT 4.0 and Windows 95 }
  212.  
  213. function OpenIMsgSession; external Mapi32Dll name 'OpenIMsgSession@12';
  214. procedure CloseIMsgSession; external Mapi32Dll name 'CloseIMsgSession@4';
  215. function OpenIMsgOnIStg; external Mapi32Dll name 'OpenIMsgOnIStg@44';
  216. function GetAttribIMsgOnIStg; external Mapi32Dll name 'GetAttribIMsgOnIStg@12';
  217. function SetAttribIMsgOnIStg; external Mapi32Dll name 'SetAttribIMsgOnIStg@16';
  218. function MapStorageSCode; external Mapi32Dll name 'MapStorageSCode@4';
  219.  
  220. end.
  221.  
  222.